/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session01;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author sinhnx <sinhnx@fpt.aptech.ac.vn>
 */
public class DatabaseInfo {
    public static void main(String[] args) {
        String url = "jdbc:sqlserver://192.168.1.51:1433;databaseName=APJII_DB;user=sinhnx;password=fat123456";
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

            Connection cn = DriverManager.getConnection(url);

            DatabaseMetaData db = cn.getMetaData();
            System.out.println("Database Server Infomation:");
            System.out.println("\t" + db.getDatabaseProductName());
            System.out.println("\t" + db.getDatabaseProductVersion());
            System.out.println("Driver Infomation:");
            System.out.println("\t"+db.getDriverName());
            System.out.println("\t"+db.getDriverVersion());
            
            cn.close();
        } catch (SQLException ex) {
            Logger.getLogger(JDBC_ODBC.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(JDBC_ODBC.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
